﻿<%@ Page Language="C#" MasterPageFile="~/admin/Admin.Master" AutoEventWireup="true" Codebehind="articleList.aspx.cs" Inherits="CMS.admin.articleList" Title="Hệ thống quản trị nội dung - Quản lý tin bài" %>

<%@ Register Assembly="ComponentArt.Web.UI" Namespace="ComponentArt.Web.UI" TagPrefix="ComponentArt" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
     function TreeView1_onNodeSelect(sender, eventArgs)
      {
        cboCategory.set_text(eventArgs.get_node().get_text());
         document.getElementById('<%=hfSelect.ClientID %>').value=eventArgs.get_node().get_value();
        cboCategory.collapse();
      }
      function deleteRow(rowId)
      {           
        Grd1.Delete(Grd1.GetRowFromClientId(rowId));
      }   									   
   	 function onCallbackError(excString)
      {                
         alert(excString);        
         Grd1.Page(0); 
         return(true);
      }        
    function showHide()
    {
        if(document.getElementById('<%=chkDate.ClientID%>').checked)
           document.getElementById('<%=rangeA.ClientID%>').disabled=false;
        else
           document.getElementById('<%=rangeA.ClientID%>').disabled =true;
    }
    </script>

    <script type="text/javascript" src="../js/jquery-1.3.1.min.js"></script>

    <script type="text/javascript" src="../js/jquery-ui-1.7.1.custom.min.js"></script>

    <script type="text/javascript" src="../js/daterangepicker.jQuery.js"></script>

    <link rel="stylesheet" href="../css/ui.daterangepicker.css" type="text/css" />
    <link rel="stylesheet" href="../css/redmond/jquery-ui-1.7.1.custom.css" type="text/css"
        title="ui-theme" />

    <script type="text/javascript">	
			$(function(){
			        //var id = <%=rangeA.ClientID %>;
			      //var a = Document.getElementById("<%=rangeA.ClientID%>");
				  $('#<%= rangeA.ClientID %>').daterangepicker({arrows:true}); 
			 });
		</script>

    <div style="border: solid 1px #ccc;">
        <div id="toolbox">
            <div class="header" style="float: left; margin-left: -40px;">
                <img src="../images/Toolbox/icon-48-article-add.png" alt="" id="imgHeader" />
                Quản lý bài viết: danh sách
            </div>
            <div style="float: right;">
                <table class="toolbar">
                    <tr>
                        <td align="center">
                            <asp:LinkButton ID="btnAddNew" runat="server" OnClick="btnAddNew_Click">
                                <asp:Label ID="lblAction" CssClass="Icon-32-Add" runat="server" />
                                Thêm mới
                            </asp:LinkButton>
                        </td>
                        <td align="center">
                            <asp:LinkButton ID="btnEdit" runat="server" OnClick="btnEdit_Click">
                                <asp:Label ID="Label1" CssClass="Icon-32-Edit" runat="server" />
                                Chỉnh sửa
                            </asp:LinkButton>
                        </td>
                        <td align="center">
                            <asp:LinkButton ID="btnDelete" runat="server" OnClick="btnDelete_Click" OnClientClick="return confirm('Bạn thực sự muốn xóa bản ghi này chứ?');">
                                <asp:Label ID="Label2" CssClass="Icon-32-Delete" runat="server" />
                                Xóa
                            </asp:LinkButton>
                        </td>
                        <td align="center">
                            <asp:LinkButton ID="btnActive" runat="server" OnClick="btnActive_Click">
                                <asp:Label ID="Label3" CssClass="Icon-32-Publish" runat="server" />
                                Xuất bản
                            </asp:LinkButton>
                        </td>
                        <td align="center">
                            <asp:LinkButton ID="btnInActive" runat="server" OnClick="btnInActive_Click">
                                <asp:Label ID="Label4" CssClass="Icon-32-UnPublish" runat="server" />
                                Chờ duyệt
                            </asp:LinkButton>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <p align="center">
        <br />
        <asp:Label ID="lblMessage" runat="server" BackColor="White" BorderColor="White" ForeColor="Red"></asp:Label>
        <asp:HiddenField ID="hfSelect" runat="Server" />
    </p>
    <div id="content-box">
        <div class="t">
            <div class="t">
                <div class="t">
                </div>
            </div>
        </div>
        <div class="m" style="height: 100%;">
            <table cellpadding="5" cellspacing="2" width="100%">
                <tr>
                    <td align="right">
                        <strong>Chuyên mục:</strong>
                    </td>
                    <td style="text-align: left;">
                        <ComponentArt:ComboBox ID="cboCategory" runat="server" KeyboardEnabled="false" AutoFilter="false"
                            AutoHighlight="false" AutoComplete="false" CssClass="comboBox" HoverCssClass="comboBoxHover"
                            FocusedCssClass="comboBoxHover" TextBoxCssClass="comboTextBox" DropDownCssClass="comboDropDown"
                            ItemCssClass="comboItem" ItemHoverCssClass="comboItemHover" SelectedItemCssClass="comboItemHover"
                            DropHoverImageUrl="../images/drop_hover.gif" DropImageUrl="../images/drop.gif"
                            Width="360" DropDownHeight="400" DropDownWidth="360">
                            <DropDownContent>
                                <ComponentArt:TreeView ID="TreeView1" DragAndDropEnabled="false" NodeEditingEnabled="false"
                                    KeyboardEnabled="true" CssClass="TreeView" NodeCssClass="TreeNode" SelectedNodeCssClass="SelectedTreeNode"
                                    HoverNodeCssClass="HoverTreeNode" NodeEditCssClass="NodeEdit" LineImageWidth="19"
                                    LineImageHeight="20" DefaultImageWidth="16" BorderColor="white" DefaultImageHeight="16"
                                    ItemSpacing="0" NodeLabelPadding="3" LineImagesFolderUrl="../images/lines/" Height="400"
                                    Width="360" ShowLines="true" EnableViewState="true" runat="server">
                                    <ClientEvents>
                                        <NodeSelect EventHandler="TreeView1_onNodeSelect" />
                                    </ClientEvents>
                                </ComponentArt:TreeView>
                            </DropDownContent>
                            <DropDownFooter>
                            </DropDownFooter>
                        </ComponentArt:ComboBox>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <strong>Trạng thái:</strong>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="ddlStatus" runat="Server" Width="360px">
                            <asp:ListItem Text="--Tất cả--" Value="-1"> </asp:ListItem>
                            <asp:ListItem Text="Chờ duyệt" Value="0"> </asp:ListItem>
                            <asp:ListItem Text="Xuất bản" Value="1"> </asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <strong>Ngày:</strong>
                        <asp:CheckBox ID="chkDate" runat="Server" onclick="showHide();" />
                    </td>
                    <td align="left">
                        <div id="tblDate" style="float: left;">
                            <asp:TextBox ID="rangeA" runat="Server" Text="27/7/2010" Height="18px" Enabled="false"></asp:TextBox>
                        </div>
                        <div style="float: left;margin-left:15px;vertical-align:baseline;">
                            <strong>Tiêu đề</strong>
                            <asp:TextBox ID="txtTitle" style="height:23px;vertical-align:baseline;" runat="Server" Width="250px"></asp:TextBox>
                            &nbsp; &nbsp; &nbsp;
                            <asp:ImageButton  ID="ImgSearch" ImageUrl="../images/btnSearch.jpg" runat="server"
                                OnClick="ImgSearch_Click" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                    </td>
                    <td align="left">
                    </td>
                </tr>
            </table>
            <br />
            <asp:Label ID="lblGrid" runat="server" BackColor="White" BorderColor="White" ForeColor="Red"></asp:Label>
            <br />
            <table cellpadding="5" cellspacing="2" width="100%">
                <tr>
                    <td>
                        <ComponentArt:Grid ID="Grd1" EnableViewState="true" AllowEditing="true" EditOnClickSelectedItem="false"
                            ClientSideOnCallbackError="onCallbackError" ShowHeader="False" CssClass="Grid"
                            KeyboardEnabled="false" FooterCssClass="GridFooter" RunningMode="Callback" AutoCallBackOnDelete="true"
                            AllowHtmlContent="true" PagerStyle="Numbered" PagerTextCssClass="PagerText" PageSize="20"
                            ImagesBaseUrl="../images/" LoadingPanelClientTemplateId="LoadingFeedbackTemplate"
                            ManualPaging="true" Width="830" LoadingPanelPosition="MiddleCenter" runat="server">
                            <Levels>
                                <ComponentArt:GridLevel RowCssClass="Row" SelectedRowCssClass="SelectedRow" AlternatingRowCssClass="AlternatingRow"
                                    DataCellCssClass="DataCell" HeadingCellCssClass="HeadingCell" HeadingTextCssClass="HeadingCellText"
                                    SortAscendingImageUrl="asc.gif" SortDescendingImageUrl="desc.gif" SortImageWidth="9"
                                    SortImageHeight="5">
                                    <Columns>
                                        <ComponentArt:GridColumn Align="Center" DataCellClientTemplateId="chkTemplate" DataField="articleId"
                                            HeadingText="<img src='../images/selected.gif' border='0' />" Width="40" AllowSorting="false" />
                                        <ComponentArt:GridColumn DataField="title" HeadingText="Tiêu đề" TextWrap="true"
                                            Width="300" />
                                        <ComponentArt:GridColumn DataField="categoryName" DataCellServerTemplateId="categoryTemplate"
                                            HeadingText="Chuyên mục" TextWrap="true" Width="250" />
                                        <ComponentArt:GridColumn DataField="createDate" HeadingText="Ngày tạo" Width="80" />
                                        <ComponentArt:GridColumn DataField="status" HeadingText="Xuất bản" Width="60" AllowSorting="false"
                                            DataCellClientTemplateId="StatusTemplate" />
                                        <ComponentArt:GridColumn DataField="articleId" AllowSorting="false" HeadingText="Xem"
                                            Width="40" DataCellServerTemplateId="PreviewTemplate" EditControlType="EditCommand"
                                            Align="Center" />
                                        <ComponentArt:GridColumn DataField="articleId" AllowSorting="false" HeadingText="Sửa"
                                            Width="40" DataCellServerTemplateId="EditTemplate" EditControlType="EditCommand"
                                            Align="Center" />
                                        <ComponentArt:GridColumn DataField="articleId" AllowSorting="false" HeadingText="Xóa"
                                            Width="40" DataCellClientTemplateId="DeleteTemplate" EditControlType="EditCommand"
                                            Align="Center" />
                                    </Columns>
                                </ComponentArt:GridLevel>
                            </Levels>
                            <ClientTemplates>
                                <ComponentArt:ClientTemplate ID="chkTemplate" runat="server">
                                    <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                        <tr>
                                            <td align="center" style="padding-left: 0px;">
                                                <input type="checkbox" class="checkbox" value="## DataItem.GetMember('articleId').Value ##"
                                                    name="articleId" id="articleId" />
                                            </td>
                                        </tr>
                                    </table>
                                </ComponentArt:ClientTemplate>
                                <ComponentArt:ClientTemplate ID="StatusTemplate" runat="server">
                                    <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                        <tr>
                                            <td align="center" style="padding-left: 5px;">
                                                ## if(DataItem.GetMember("status").Value == 1) { '<img src="../images/tick.png" border="0" />'
                                                } ## ## if(DataItem.GetMember("status").Value == 0) { '<img src="../images/publish_x.png"
                                                    border="0" />' } ##
                                            </td>
                                        </tr>
                                    </table>
                                </ComponentArt:ClientTemplate>
                                <ComponentArt:ClientTemplate ID="DeleteTemplate" runat="server">
                                    <a href="javascript:deleteRow('## DataItem.ClientId ##')" onclick="return confirm('Bạn thực sự muốn xóa bản ghi này chứ?');">
                                        <img src="../images/delete.gif" border="0" title="Xóa" /></a>
                                </ComponentArt:ClientTemplate>
                                <ComponentArt:ClientTemplate ID="LoadingFeedbackTemplate" runat="server">
                                    <table cellspacing="0" cellpadding="0" border="0">
                                        <tr>
                                            <td style="font-size: 10px;">
                                                Đang tải...&nbsp;</td>
                                            <td>
                                                <img src="../images/spinner.gif" border="0"></td>
                                        </tr>
                                    </table>
                                </ComponentArt:ClientTemplate>
                            </ClientTemplates>
                            <ServerTemplates>
                                <ComponentArt:GridServerTemplate ID="categoryTemplate" runat="Server">
                                    <Template>
                                        <%# GetCategoryPath(Int32.Parse(Container.DataItem["articleId"].ToString()))%>
                                    </Template>
                                </ComponentArt:GridServerTemplate>
                                <ComponentArt:GridServerTemplate ID="PreviewTemplate" runat="Server">
                                    <Template>
                                        <a href="#" onclick="window.open('articleView.aspx?Id=<%# HttpUtility.UrlEncode(Common.DAL.Encrypt(Container.DataItem["articleId"].ToString())) %>','mywindow','location=1,status=1,scrollbars=1,width=550,height=600')">
                                            <img src="../images/Preview.png" border="0" title="Xem trước" /></a>
                                    </Template>
                                </ComponentArt:GridServerTemplate>
                                <ComponentArt:GridServerTemplate ID="EditTemplate" runat="Server">
                                    <Template>
                                        <a href="articleAE.aspx?Id=<%# HttpUtility.UrlEncode(Common.DAL.Encrypt(Container.DataItem["articleId"].ToString())) %>">
                                            <img src="../images/edit.gif" border="0" title="Sửa" /></a>
                                    </Template>
                                </ComponentArt:GridServerTemplate>
                            </ServerTemplates>
                        </ComponentArt:Grid>
                    </td>
                </tr>
            </table>
            <div class="clr">
            </div>
        </div>
        <div class="b">
            <div class="b">
                <div class="b">
                </div>
            </div>
        </div>
    </div>
</asp:Content>
